﻿using EFCore3.Entity;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace EFCore3.EntityConfig
{
    public class DeliveryConfig : IEntityTypeConfiguration<Delivery>
    {
        public void Configure(EntityTypeBuilder<Delivery> builder)
        {
            builder.ToTable("T_Delivery").HasKey(p => p.Id);
            builder.HasOne(p => p.Order).WithOne(p => p.Delivery).IsRequired().HasForeignKey<Delivery>(p => p.OrderId);
        }
    }
}
